package com.vecspace.dayu.code.common;

import javax.persistence.Transient;

import org.apache.commons.lang3.StringUtils;

import com.google.common.base.CaseFormat;

public class CodeUtil {
	/**
	 * 首字母小写的变量名
	 * @param columnName
	 * @return
	 */
	public String getVarName(String columnName) {		
		if(columnName == null)return "";
		columnName = columnName.trim().toUpperCase();		
		while(columnName.startsWith("_")) columnName = columnName.substring(1);
		while(columnName.endsWith("_")) columnName = columnName.substring(0, columnName.length()-1);
		String varName = CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, columnName);
		return varName;
	}
	
	/**首字母大写的变量名
	 * 
	 * @return 
	 * @author wanghua
	 */
	public String getPropName(String columnName) {
		if(columnName == null)return "";
		columnName = columnName.trim().toUpperCase();
		
		while(columnName.startsWith("_")) columnName = columnName.substring(1);
		while(columnName.endsWith("_")) columnName = columnName.substring(0, columnName.length()-1);
		String varName = CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, columnName);
		return varName;
	}
}
